home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 22
/
AACD 22.iso
/
AACD
/
Resources
/
General
/
ProNET
/
src
/
utilities
/
pronet-talk.s
< prev
Wrap
Text File
|
1996-10-01
|
7KB
|
372 lines
*
* pronet-talk.s
*
CSI equ 27+128
include "A:OSmacros.i"
include "exec/exec.i"
include "intuition/intuition.i"
include "p:include/devices/pronet.i"
include "exec_lib.i"
include "intuition_lib.i"
j bsr dec2long * UNIT as Argument
move.l d1,unit
lea wintitle2mod(pc),a0
move.l unit(pc),d0
bsr long2dec
clr.b (a0)+
move.l 4.w,a6
lea intname(pc),a1
LIBCALL OldOpenLibrary
move.l d0,intbase
bsr initconsole
tst.w d0
bne noconsole
bsr startpronet
tst.w d0
bne nopronet
move.l intbase(pc),a6
move.l window(pc),a0
lea wintitle2(pc),a1
move.l a1,a2
LIBCALL SetWindowTitles
bsr Wait4Message
bsr stoppronet
nopronet bsr closeconsole
noconsole move.l intbase(pc),a1
move.l 4.w,a6
LIBCALL CloseLibrary
moveq #0,d0
rts
dc.b "$VER: pronet-talk 37.1 (1.10.96)",13,10,0
even
initconsole move.l intbase(pc),a6 ;Window öffnen
cmp.w #36,LIB_VERSION(a6)
bcs.s .nokick2
lea wbname(pc),a0
LIBCALL LockPubScreen
move.l d0,wbscreen
beq icnoscr
move.l d0,a0
moveq #0,d1
move.b sc_WBorTop(a0),d1
add.b sc_WBorBottom(a0),d1
add.w sc_RastPort+rp_TxHeight(a0),d1
add.w #2+100,d1
move.w d1,newwindow+6
.nokick2 lea newwindow(pc),a0
LIBCALL OpenWindow
move.l d0,window
beq icnowin
moveq #48,d0 ;Console-Device öffnen
bsr GetIORequest
move.l d0,conreadio
beq nodevblock1
moveq #48,d0
bsr GetIORequest
move.l d0,conwriteio
beq nodevblock2
move.l conreadio(pc),a1
move.l window(pc),IO_DATA(a1)
lea consolename(pc),a0
moveq #0,d0
moveq #0,d1
move.l 4.w,a6
LIBCALL OpenDevice
tst.l d0
bne nocondev
move.l conreadio(pc),a0
move.l conwriteio(pc),a1
move.l 20(a0),20(a1)
move.l 24(a0),24(a1)
move.l window(pc),a0
move.l wd_UserPort(a0),a0
move.b MP_SIGBIT(a0),Signal.window
move.l conreadio(pc),a0
move.l MN_REPLYPORT(a0),a0
move.b MP_SIGBIT(a0),Signal.console
bsr sendconreadcmd
moveq #0,d0
rts
sendconreadcmd move.l 4.w,a6
moveq #0,d0
moveq #0,d1
move.l conreadio(pc),a0
move.l MN_REPLYPORT(a0),a0
move.b MP_SIGBIT(a0),d2
bset d2,d1
LIBCALL SetSignal
move.l conreadio(pc),a1
clr.b IO_FLAGS(a1)
move.l #256,IO_LENGTH(a1)
move.l #conbuf,IO_DATA(a1)
move.w #CMD_READ,IO_COMMAND(a1)
LIBCALL SendIO
rts
closeconsole move.l 4.w,a6
move.l conreadio(pc),a1
LIBCALL CloseDevice
nocondev move.l conwriteio(pc),a0
bsr FreeIORequest
nodevblock2 move.l conreadio(pc),a0
bsr FreeIORequest
nodevblock1 move.l intbase(pc),a6
move.l window(pc),a0
LIBCALL CloseWindow
icnowin cmp.w #36,LIB_VERSION(a6)
bcs.s icnoscr
sub.l a0,a0
move.l wbscreen(pc),a1
LIBCALL UnlockPubScreen
icnoscr moveq #-1,d0
rts
startpronet moveq #pnr_Size,d0
bsr GetIORequest
move.l d0,pronetio
beq spnoioreq
bsr CreatePort
move.l d0,msgport
beq spnomsgport
lea pronetname,a0
move.l unit(pc),d0
moveq #0,d1
move.l pronetio(pc),a1
move.w #$8000,pnr_NetSourcePort(a1)
move.l msgport(pc),pnr_MsgPort(a1)
move.l 4.w,a6
LIBCALL OpenDevice
tst.l d0
bne spnodev
move.l pronetio(pc),a1
move.w pnr_NetSourcePort(a1),pnr_NetDestPort(a1)
move.l msgport(pc),a0
move.b MP_SIGBIT(a0),Signal.pronet
moveq #0,d0
rts
stoppronet move.l 4.w,a6
move.l pronetio(pc),a1
LIBCALL CloseDevice
spnodev move.l msgport(pc),a0
bsr DeletePort
spnomsgport move.l pronetio(pc),a0
bsr FreeIORequest
spnoioreq moveq #-1,d0
rts
dec2long ; konvertiert Dezimalstring ab (a0) zu Longword in D1 !!
moveq #0,d1
.loop moveq #0,d0
move.b (a0)+,d0
sub.b #"0",d0
cmp.b #9,d0
bhi.s .oki
move.l d1,d2
lsl.l #3,d1
add.l d2,d1
add.l d2,d1
add.l d0,d1
bra.s .loop
.oki rts
long2dec ;Converts Long in d0 to Dec-String in (a0)+
tst.l d0
bne.s .0
move.b #"0",(a0)+
rts
.0 lea long2asciitab(pc),a1
moveq #9,d1
moveq #0,d6
.1 move.l (a1)+,d2
move.l d0,d3
moveq #-1,d4
.2 move.l d3,d5
sub.l d2,d3
cmp.l d5,d3
dbhi d4,.2
add.l d2,d3
move.l d3,d0
not.w d4
bne.s .3
tst.w d6
beq.s .4
.3 st d6
add.b #"0",d4
move.b d4,(a0)+
.4 dbra d1,.1
rts
long2asciitab dc.l 1000000000,100000000,10000000,1000000,100000
dc.l 10000,1000,100,10,1
w4mquitflag dc.w 0
Wait4Message tst.w w4mquitflag
bne .quit
clr.w w4mquitflag
lea Signals(pc),a3 * auf die Messages
moveq #0,d0 * an allen möglichen
moveq #numports-1,d1 * Ports warten
.loop1 move.b (a3),d2
bmi.s .0
bset d2,d0
.0 addq.w #6,a3
dbra d1,.loop1
move.l 4.w,a6
LIBCALL Wait
* entsprechende Routinen
moveq #31,d7 * aufrufen
.00 rol.l d0
bcc.s .notthisbit
lea Signals(pc),a3
moveq #numports-1,d4
.01 cmp.b (a3),d7
bne.s .notthisport
movem.l d0/d4/d7/a3,-(sp)
move.l 2(a3),a3
jsr (a3)
movem.l (sp)+,d0/d4/d7/a3
.notthisport addq.w #6,a3
dbra d4,.01
.notthisbit dbra d7,.00
bra Wait4Message
.quit rts
Signals:
Signal.window dc.b -1,0 ;Signalbit
dc.l EvalWindowMessage ;Entsprechende Routine
Signal.pronet dc.b -1,0
dc.l ReadFromProNET
Signal.console dc.b -1,0
dc.l ReadFromConsole
numports equ 3
EvalWindowMessage ; IDCMP-Flags des Window wurden aufgerufen
move.l 4.w,a6
move.l window(pc),a0
move.l wd_UserPort(a0),a0
LIBCALL GetMsg
move.l d0,a1
tst.l d0
beq.s .ende
move.l $14(a1),d4 ;Class
move.w $18(a1),d5 ;Code
move.w $1a(a1),d6 ;Qualifier
move.l $1c(a1),a4 ;IAddress
cmp.l #IDCMP_CLOSEWINDOW,d4
bne.s .0
st w4mquitflag
.0 LIBCALL ReplyMsg
bra.s EvalWindowMessage
.ende rts
ReadFromProNET ; Message vom anderen Rechner
move.l 4.w,a6
move.l msgport(pc),a0
LIBCALL GetMsg
tst.l d0
beq.s .ende
move.l d0,a3
move.l conwriteio(pc),a1
move.w #CMD_WRITE,IO_COMMAND(a1)
move.l a3,d0
add.l #MN_SIZE+4,d0
move.l d0,IO_DATA(a1)
move.l MN_SIZE(a3),d0
move.l d0,IO_LENGTH(a1)
clr.b IO_FLAGS(a1)
LIBCALL DoIO ;und auf der Console ausgeben
move.l a3,a1
LIBCALL ReplyMsg
bra.s ReadFromProNET
.ende rts
ReadFromConsole ; Es wurde auf der Console etwas getippt
move.l conreadio(pc),a0
move.l IO_ACTUAL(a0),d6 ;Anzahl der Bytes
bsr processconbuf
move.l conwriteio(pc),a1
move.w #CMD_WRITE,IO_COMMAND(a1)
move.l #conbuf,IO_DATA(a1)
move.l d6,IO_LENGTH(a1)
clr.b IO_FLAGS(a1)
LIBCALL DoIO ;auf der Console ausgeben
move.l pronetio(pc),a1
move.w #CMD_WRITE,IO_COMMAND(a1)
lea conbuf-4,a0
move.l a0,pnr_Data(a1)
move.l d6,(a0)
addq.l #1,d6
bclr #0,d6 ;aufrunden
addq.l #4,d6 ;Längenwort !
move.l d6,pnr_Length(a1)
LIBCALL DoIO ;und auf dem anderen Amiga
bsr sendconreadcmd ;neue Sachen lesen
rts
processconbuf ; Ein paar Tasten umdefinieren (Cursor, Del etc.)
; alte Länge der Daten in D6.l
; muß neue Länge in D6.l zurückgeben
rts
; - Data ------------------------------------------------------------------
pronetname dc.b "pronet.device",0
consolename dc.b "console.device",0
intname dc.b "intuition.library",0
wbname dc.b "Workbench",0
even
newwindow dc.w 50,50
dc.w 400,114
dc.b -1,-1
dc.l IDCMP_CLOSEWINDOW,$1100e,0,0,wintitle,0,0
dc.w -1,-1,-1,-1,$1
wintitle dc.b "ProNET-Talk! - Starting ProNET..",0
wintitle2 dc.b "ProNET-Talk! Unit "
wintitle2mod dc.b "XXXXXXXX",0
;talkstr dc.b "pronet-talk:",0
even
unit dc.l 0
pronetio dc.l 0
msgport dc.l 0
intbase dc.l 0
window dc.l 0
wbscreen dc.l 0
conreadio dc.l 0
conwriteio dc.l 0
include "p:include/devio.s"
section b,bss
ds.b 4
conbuf ds.b 256